#ifndef RECORDDATABASE_H
#define RECORDDATABASE_H

#include "Database.h"

#include <QList>

class Record
{
public:
    Record();

    int recordId;

    float temperature, weight, bloodGlucose;
    int bloodPressureSystolic, bloodPressureDiastolic,
        respiratoryRate, pulseRate;

    QString comment, observationDate;
};

class RecordDatabaseModel : public QAbstractTableModel
{
public:
    RecordDatabaseModel();
    void setSource(QList<Record> *records);

    int rowCount(const QModelIndex &parent) const;
    int columnCount(const QModelIndex &parent) const;

    QVariant data(const QModelIndex &index, int role) const;
    QVariant headerData(int section, Qt::Orientation orientation, int role) const;

private:
    int rowNum, colNum;
    QList<Record> *records;
};

class RecordDatabase : protected Database
{
public:
    RecordDatabase();
    ~RecordDatabase();

    void initDatabase();
    void loadRecords(int userId);
    void addRecord(const Record * record, int userId);

    RecordDatabaseModel * getModel();

    QList<Record> * getRecords();
    int getRecordCount();

private:
    int recordCount;
    QList<Record> records;

    RecordDatabaseModel model;
};

#endif // RECORDDATABASE_H
